package com.gitee.chili.leisure.api;

import com.gitee.chili.leisure.ResponseResult;
import com.gitee.chili.leisure.annotation.PathRestController;
import com.gitee.chili.leisure.domain.dto.RequestModel;
import com.gitee.chili.leisure.service.MahjongService;
import com.gitee.chili.leisure.util.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import sun.invoke.empty.Empty;

import javax.validation.Valid;

/**
 * MahjongController
 *
 * @author week solider
 * @since 2020.09.18
 */
@Validated
@PathRestController("/v1/api")
public class MahjongController {

    @Autowired
    private MahjongService mahjongService;

    @PostMapping("/begin")
    public ResponseResult<Empty> begin(@Valid @RequestBody RequestModel model){

        Long roomNum = Utils.asLong(model.getData().get("roomNum"));

        mahjongService.begin(roomNum);

        return ResponseResult.success();
    }
}
